
let axios = require("axios")
// http://ip.taobao.com/service/getIpInfo.php?ip=210.75.225.254
function getIp(ip) {
	if (ip)
		return axios.default.get("http://ip.taobao.com/service/getIpInfo.php?ip=" + ip, {
			timeout: 3000
		}).then(v => {
			let d = v.data
			if (d && d.code === 0 && d.data instanceof Object) {
				console.log(d.data)
				return [d.data.country, d.data.region, d.data.city]
			} else {
				return
			}
		})
	else {
		return Promise.reject()
	}
}

// getIp("116.22.132.168").then(console.log)
module.exports = getIp